package com.tacc.tyun.common.httpclient;

import org.apache.http.client.config.RequestConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 用来设置请求的各种配置
 * @author taocongcong
 * @create 2017-07-11 11:22
 */
@Configuration
@EnableConfigurationProperties(HttpClientProperties.class)
public class MyRequestConfig {
    @Autowired
    private HttpClientProperties httpClientProperties;

    @Bean
    public RequestConfig config(){
        return RequestConfig.custom()
                .setConnectionRequestTimeout(httpClientProperties.getConnectionRequestTimeout())
                .setConnectTimeout(httpClientProperties.getConnectTimeout())
                .setSocketTimeout(httpClientProperties.getSocketTimeout())
                .build();
    }
}
